package net.ojbk.study.twobox.web.handlers;

import net.ojbk.study.twobox.beans.vo.PayStudent;
import net.ojbk.study.twobox.service.O_PayStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

/**
 * Created with IntelliJ IDEA.
 * User: twobox
 * Date: 2019/4/17
 * Time: 20:50
 * Description: No Description
 */
@Controller
@RequestMapping("/payStu")
public class O_PayStudentController {

    @Autowired
    O_PayStudentService o_payStudentService;

    @RequestMapping(value = "", method = RequestMethod.GET)
    public ResponseEntity<Object> getAllPayStudent(Integer currentPage) throws Exception {
        if (currentPage == null || currentPage <= 0)
            currentPage = 1;
        return new ResponseEntity<>(o_payStudentService.getAll_PayStudentList(currentPage), HttpStatus.OK);
    }

    @RequestMapping(value = "allClass", method = RequestMethod.GET)
    public ResponseEntity<Object> getAllClass() throws Exception {
        return new ResponseEntity<>(o_payStudentService.getAllClass(), HttpStatus.OK);
    }

    @RequestMapping(value = "student", method = RequestMethod.POST)
    public ResponseEntity<Object> referToStudent(@Validated @RequestBody PayStudent payStudents, BindingResult br) throws Exception {
        o_payStudentService.referTOStudent(payStudents, br);
        return new ResponseEntity<>("success", HttpStatus.OK);
    }
}
